package cn.cms.chuangjia.service.impl;

import java.util.List;

import cn.cms.chuangjia.domain.Admin;
import cn.cms.chuangjia.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import cn.cms.chuangjia.mapper.AdminMapper;

/**
 * adminService业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-18
 */
@Service
@Cacheable(cacheNames = "admin",keyGenerator = "keyg")
public class AdminServiceImpl implements IAdminService
{
    @Autowired
    private AdminMapper adminMapper;

    /**
     * 查询admin
     * 
     * @param id admin主键
     * @return admin
     */
    @Override
    public Admin selectAdminById(Integer id)
    {
        return adminMapper.selectAdminById(id);
    }

    /**
     * 查询admin列表
     * 
     * @param admin admin
     * @return admin
     */
    @Override
    public List<Admin> selectAdminList(Admin admin)
    {
        return adminMapper.selectAdminList(admin);
    }

    /**
     * 新增admin
     * 
     * @param admin admin
     * @return 结果
     */
    @CacheEvict(allEntries = true,cacheNames = "admin")
    @Override
    public int insertAdmin(Admin admin)
    {
        return adminMapper.insertAdmin(admin);
    }

    /**
     * 修改admin
     * 
     * @param admin admin
     * @return 结果
     */
    @CacheEvict(allEntries = true)
    @Override
    public int updateAdmin(Admin admin)
    {
        return adminMapper.updateAdmin(admin);
    }

    /**
     * 批量删除admin
     * 
     * @param ids 需要删除的admin主键
     * @return 结果
     */
    @CacheEvict(allEntries = true)
    @Override
    public int deleteAdminByIds(Integer[] ids)
    {
        return adminMapper.deleteAdminByIds(ids);
    }

    /**
     * 删除admin信息
     * 
     * @param id admin主键
     * @return 结果
     */
    @CacheEvict(allEntries = true)
    @Override
    public int deleteAdminById(Integer id)
    {
        return adminMapper.deleteAdminById(id);
    }

    @Override
    public Admin login(Admin admin) {
        return this.adminMapper.login(admin.getLoginname(),admin.getPass());
    }
}
